//
//  XDTeacherCommentDetailsViewController.m
//  XDEducation
//
//  Created by apple on 2017/4/20.
//  Copyright © 2017年 apple. All rights reserved.
//

#import "XDTeacherCommentDetailsViewController.h"
#import "XDHomeCellHeaderView.h"
#import "XDCommentChartCell.h"
#import "XDCommentImageCell.h"
#import "XDCommentHomeworkCell.h"
@interface XDTeacherCommentDetailsViewController ()
/** header title */
@property(nonatomic,strong) NSArray *headerViewTitle;
@end

static NSString *const CommentChartCellID = @"CommentChartCell";
static NSString *const CommentHomeWorkCellID = @"CommentHomeWorkCell";

@implementation XDTeacherCommentDetailsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(backKeyboard)];
    [self.tableView addGestureRecognizer:tap];
    
}

-(NSArray *)headerViewTitle{
    if (!_headerViewTitle) {
        _headerViewTitle = [NSArray arrayWithObjects:
                            @"作业图表",
                            @"作业评价",
                            @"好成绩",
                            @"好习惯",
                            @"好素养",
                            nil];
    }
    return _headerViewTitle;
}


#pragma mark - tableview delegate
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return self.headerViewTitle.count;
    
}


-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 44;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    XDHomeCellHeaderView *headerView = [[XDHomeCellHeaderView alloc]initWithTitle:self.headerViewTitle[section] MoreBtnStatus:NO];
    
    return headerView;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    switch (section) {
        case 0:
            return 3;
            break;
        case 1:
            return 2;
            break;
        default:
            return 0;
            break;
    }
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0 && indexPath.row == 2) {
        return 70;
    }
    return 50;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    switch (indexPath.section) {
        case 0:{
            
            if (indexPath.row == 0) {
                
                [tableView registerNib:[UINib nibWithNibName:@"XDCommentChartCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:CommentChartCellID];
                XDCommentChartCell *cell = [tableView dequeueReusableCellWithIdentifier:CommentChartCellID];
                cell.titleLabel.text = @"学生账号";
                return cell;
                
            }else if(indexPath.row == 1){
                
                [tableView registerNib:[UINib nibWithNibName:@"XDCommentChartCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:CommentChartCellID];
                XDCommentChartCell *cell = [tableView dequeueReusableCellWithIdentifier:CommentChartCellID];
                cell.titleLabel.text = @"科        目";
                return cell;
            }else{
                NSArray *arr = [NSArray arrayWithObjects:@"1",@"3",@"3",@"2", nil];
                XDCommentImageCell *cell = [XDCommentImageCell cellWithTableView:tableView imageArr:arr];
                
                return cell;
            }
        }
            break;
        case 1:{
            
                [tableView registerNib:[UINib nibWithNibName:@"XDCommentHomeworkCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:CommentHomeWorkCellID];
                XDCommentHomeworkCell *cell = [tableView dequeueReusableCellWithIdentifier:CommentHomeWorkCellID];
            
            if (indexPath.row == 0) {
                cell.titleLabel.text = @"共性问题";
            }else{
                 cell.titleLabel.text = @"个性问题";
            }
                return cell;
        }
            break;
        default:{
            static NSString *ID = @"cell";
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
            if(!cell){
                cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
            }
            return cell;
            
        }
            break;
    }
}


-(void)backKeyboard{
    [self.view endEditing:YES];
}

-(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
    [self backKeyboard];
}

@end
